

echo "开始删除t_tracker_widget_show_aggregates_channel表..."
clickhouse-client --password Keepgo123@cys -q "
drop table IF EXISTS db_cfx.t_tracker_widget_show_aggregates_channel
"

echo "开始新建t_tracker_widget_show_aggregates_channel表..."
clickhouse-client --password Keepgo123@cys -q "
CREATE TABLE db_cfx.t_tracker_widget_show_aggregates_channel (
    date Date,
    hour UInt8,
    channel String,
    total_records UInt64
) ENGINE = AggregatingMergeTree()
PARTITION BY date
ORDER BY (date,hour,channel)
TTL date + toIntervalDay(7) TO VOLUME 'cold_volume', date + toIntervalDay(31)
SETTINGS index_granularity = 8192, merge_with_ttl_timeout = 86400, storage_policy = 'hot_cold_policy'
"
echo "新建db_cfx.t_tracker_widget_show_aggregates_channel表完成..."